Code coverage report for src/browser/rollbarWrapper.js

Statements: 10% (2 / 20)      Branches: 0% (0 / 6)      Functions: 0% (0 / 5)      Lines: 10% (2 / 20)      Ignored: none     

All files » src/browser/ » rollbarWrapper.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                1                        
function RollbarWrap(impl, options) {
  this.impl = impl(options, this);
  this.options = options;
  _setupForwarding(RollbarWrap.prototype);
}

function _setupForwarding(prototype) {
  var _forward = function(method) {
    return function() {
      var args = Array.prototype.slice.call(arguments, 0);
      if (this.impl[method]) {
        return this.impl[method].apply(this.impl, args);
      }
    };
  };
 
  var _methods = 'log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,_createItem,wrap,loadFull,shimId'.split(',');
  for (var i=0; i<_methods.length; i++) {
    prototype[_methods[i]] = _forward(_methods[i]);
  }
}
 
RollbarWrap.prototype._swapAndProcessMessages = function(impl, messages) {
  this.impl = impl(this.options);
  var msg, method, args;
  while ((msg = messages.shift())) {
    method = msg.method;
    args = msg.args;
    if (this[method] && typeof this[method] === 'function') {
      this[method].apply(this, args);
    }
  }
  return this;
};

module.exports = RollbarWrap;